﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WPFCalculadora
{
    /// <summary>
    /// Lógica de interacción para Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        EML operador1= new EML("0");

        public enum TOperacio
        {
            suma,
            resta
        }

        TOperacio operacio;

        public Window1()
        {
            InitializeComponent();
        }

        private void suma_Click(object sender, RoutedEventArgs e)
        {
            operador1 = new EML(this.Display.Text);
            operacio = TOperacio.suma;
            this.Display.Text = "";
        }

        private void igual_Click(object sender, RoutedEventArgs e)
        {
            EML operador2 = new EML(this.Display.Text);
            if (operacio == TOperacio.suma)
            {
                EML resultat = operador1.suma(operador2);
                this.Display.Text = resultat.ToString();
            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button b = (Button)sender;
            this.Display.Text = this.Display.Text + b.Content;
        }
    }
}
